﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Samples.WindowsAzure.ServiceManagement;

namespace WAPA.Framework
{
    /// <summary>
    /// Abstraction for cleaning up a hosted service environment. This includes related deployments, queues etc.
    /// </summary>
    public class DeleteHostedServicesAction : IAction
    {
        public HostedServiceList HostedServices;

        public DeleteHostedServicesAction()
        {
            HostedServices = new HostedServiceList();
        }

        public void Execute()
        {
            foreach (HostedService hostedService in HostedServices)
            {
                //To clean up we also remove related queues.
                CloudServiceManager.DeleteQueue(hostedService.ServiceName);

                CloudServiceManager.DeleteHostedService(hostedService.ServiceName);
            }
        }
    }
}
